/**
 * 
 */
package top.lcpsky.flashcards.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import top.lcpsky.flashcards.entity.Stock;
import top.lcpsky.flashcards.mapper.StockMapper;

/**
 * @ClassName: StockService
 * @author: lcp
 * @date: 2020年7月9日 下午2:43:26
 * 
 * @Copyright: 2020 www.ankept.com Inc. All rights reserved.
 */
@Service
public class StockService {
	@Autowired
	private StockMapper stockMapper;

	public List<Stock> getAllStocks() {
		return stockMapper.findAll();
	}

	/**
	 * @return @Title: getStockChecked @param: @return: void @throws
	 */
	public List<Stock> getStockChecked() {
		return stockMapper.getEnableStock();
	}

	/**
	 * @Title: enableStock @param: @param code @return: void @throws
	 */
	public Boolean enableStock(String code) {
		Stock stock = stockMapper.selectByPrimaryKey(code);
		try {
			if (stock != null) {
				stock.setEnable(true);
				stockMapper.updateByPrimaryKey(stock);
			}
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

}
